package com.anolesoft.secondaryCostAccounting.service.impl;

import com.anolesoft.secondaryCostAccounting.dto.*;
import com.anolesoft.secondaryCostAccounting.mapper.MatchServiceMapper;
import com.anolesoft.secondaryCostAccounting.mapper.SqlserverMatchServiceMapper;
import com.anolesoft.secondaryCostAccounting.service.MatchService;
import com.anolesoft.secondaryCostAccounting.util.NumStringUtil;
import com.anolesoft.secondaryCostAccounting.util.SqlserverData;
import com.anolesoft.yr.util.CommonUtils;
import com.anolesoft.yr.util.PageData;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Service
@Slf4j
public class MatchServiceImpl implements MatchService {

    @Autowired
    MatchServiceMapper matchServiceMapper;
    @Autowired
    SqlserverMatchServiceMapper sqlserverMatchServiceMapper;
    @Autowired
    MatchService matchService;

    @Override
    public PageData<List<MatchDO>> queryMatchInfo(MatchConditionDTO matchConditionDTO, boolean isExport){
        Page<MatchDO> page = new Page<>(matchConditionDTO.getPageNo(),matchConditionDTO.getPageSize());
        List<MatchDO> matchInfoDTOS;
        if (isExport) {
            matchInfoDTOS = matchServiceMapper.exportMatchInfo(matchConditionDTO,page);
        } else {
            matchInfoDTOS = matchServiceMapper.queryMatchInfoSQL(matchConditionDTO,page);
        }
        return new PageData<>((int) page.getTotal(),matchInfoDTOS);
    }

    @Override
    public SqlserverData matchSCA(MatchInfoDTO matchInfoDTO) {
        List<SCAccountingDTO> matchSCA = new ArrayList<>();
        String paihao = matchInfoDTO.getMaterialMark();
        String guige = matchInfoDTO.getMaterialFmt();
        String factoryId = matchInfoDTO.getFactoryId();
        String objuid = matchInfoDTO.getObjuid();
        String issueNum = matchInfoDTO.getIssueNum();
        boolean likeGuiGe = false;
        if (guige.indexOf("δ") != -1) {
            likeGuiGe = true;
            if (guige.indexOf("X") != -1) {
                matchInfoDTO.setMaterialFmt(guige.split("X")[0]);
            }
            if (guige.indexOf("×") != -1) {
                matchInfoDTO.setMaterialFmt(guige.split("×")[0]);
            }
        }
        List<SCAccountingDTO> match = this.matchService.match(matchInfoDTO,likeGuiGe);
        if (match.size() > 0) {
            List<MesAccountMatchCompleteDTO> complete = complete(match,factoryId);
            matchSCA = check(complete,match,objuid,issueNum,3);
        }
        if (paihao.indexOf("/") != -1) {
            String[] paihaoList = paihao.split("\\/");
            for (int i = 0; i < paihaoList.length && matchSCA.size() <= 0; i++) {
                String s = paihaoList[i];
                matchInfoDTO.setMaterialMark(s);
                match = this.matchService.match(matchInfoDTO,likeGuiGe);
                if (match.size() > 0) {
                    List<MesAccountMatchCompleteDTO> complete = complete(match,factoryId);
                    matchSCA = check(complete,match,objuid,issueNum,3);
                }
            }
        }
        if (matchSCA.size() > 0) {
            NumStringUtil numStringUtil = new NumStringUtil();
            for (SCAccountingDTO s: matchSCA) {
                String stock = s.getStock();
                if (numStringUtil.numCompareTo(issueNum,stock).equals("1")) {
                    issueNum = numStringUtil.numSub(issueNum,stock);
                    s.setBangdingnum(stock);
                    s.setSfAmount(numStringUtil.numDiv(numStringUtil.numMul(stock,s.getAccountPrice()),"1"));
                } else {
                    s.setBangdingnum(issueNum);
                    s.setSfAmount(numStringUtil.numDiv(numStringUtil.numMul(issueNum,s.getAccountPrice()),"1"));
                    break;
                }
            }
        }
        SqlserverData sqlserverData;
        EmployeeFromSCADTO employee = this.matchService.employee(matchInfoDTO.getPickMan());
        log.debug("employee:{}",employee);
        if (employee == null) {
            sqlserverData = SqlserverData.builder()
                    .data(matchSCA)
                    .gongduan("null")
                    .banzu("null")
                    .build();
        } else {
            sqlserverData = SqlserverData.builder()
                    .data(matchSCA)
                    .gongduan(employee.getGongduan())
                    .banzu(employee.getBanzu())
                    .build();
        }
        return sqlserverData;
    }

    /**
    @Override
    public SqlserverData matchSCA(MatchInfoDTO matchInfoDTO) {
        List<SCAccountingDTO> matchSCA = new ArrayList<>();
        String paihao = matchInfoDTO.getMaterialMark();
        String unit = matchInfoDTO.getUnit();
        String guige = matchInfoDTO.getMaterialFmt();
        String factoryId = matchInfoDTO.getFactoryId();
        String objuid = matchInfoDTO.getObjuid();
        String issueNum = matchInfoDTO.getIssueNum();
        boolean likeDanWei = false;
        boolean likeGuiGe = false;
        //if (unit.toUpperCase().indexOf("KG") != -1 || unit.indexOf("千克") != -1) {
        //    likeDanWei = true;
        //    matchInfoDTO.setUnit("'kg','千克'");
        //}
        //if (unit.toUpperCase().indexOf("M") != -1 || unit.indexOf("米") != -1) {
        //    likeDanWei = true;
        //    matchInfoDTO.setUnit("'m','米'");
        //}
        if (guige.indexOf("δ") != -1) {
            likeGuiGe = true;
            if (guige.indexOf("X") != -1) {
                matchInfoDTO.setMaterialFmt(guige.split("X")[0]);
            }
            if (guige.indexOf("×") != -1) {
                matchInfoDTO.setMaterialFmt(guige.split("×")[0]);
            }
        }
        if (this.matchService.matchNum(matchInfoDTO,likeGuiGe,likeDanWei) != 0) {
            for (int i = 0; i < 4 && matchSCA.size() <= 0; i++) {
                List<SCAccountingDTO> match = this.matchService.match(matchInfoDTO,i,likeGuiGe,likeDanWei);
                if (match.size() > 0) {
                    List<MesAccountMatchCompleteDTO> complete = complete(match,factoryId);
                    matchSCA = check(complete,match,objuid,issueNum,i);
                }
            }
        }
        if (paihao.indexOf("/") != -1) {
            String[] paihaoList = paihao.split("\\/");
            for (int i = 0; i < paihaoList.length && matchSCA.size() <= 0; i++) {
                String s = paihaoList[i];
                matchInfoDTO.setMaterialMark(s);
                if (this.matchService.matchNum(matchInfoDTO,likeGuiGe,likeDanWei) != 0) {
                    for (int j = 0; j < 4 && matchSCA.size() <= 0; j++) {
                        List<SCAccountingDTO> match = this.matchService.match(matchInfoDTO,j,likeGuiGe,likeDanWei);
                        if (match.size() > 0) {
                            List<MesAccountMatchCompleteDTO> complete = complete(match,factoryId);
                            matchSCA = check(complete,match,objuid,issueNum,i);
                        }
                    }
                }
            }
        }
        if (matchSCA.size() > 0) {
            NumStringUtil numStringUtil = new NumStringUtil();
            for (SCAccountingDTO s: matchSCA) {
                String stock = s.getStock();
                if (numStringUtil.numCompareTo(issueNum,stock).equals("1")) {
                    issueNum = numStringUtil.numSub(issueNum,stock);
                    s.setBangdingnum(stock);
                    s.setSfAmount(numStringUtil.numDiv(numStringUtil.numMul(stock,s.getAccountPrice()),"1"));
                } else {
                    s.setBangdingnum(issueNum);
                    s.setSfAmount(numStringUtil.numDiv(numStringUtil.numMul(issueNum,s.getAccountPrice()),"1"));
                    break;
                }
            }
        }
        SqlserverData sqlserverData;
        EmployeeFromSCADTO employee = this.matchService.employee(matchInfoDTO.getPickMan());
        log.debug("employee:{}",employee);
        if (employee == null) {
            sqlserverData = SqlserverData.builder()
                    .data(matchSCA)
                    .gongduan("null")
                    .banzu("null")
                    .build();
        } else {
            sqlserverData = SqlserverData.builder()
                    .data(matchSCA)
                    .gongduan(employee.getGongduan())
                    .banzu(employee.getBanzu())
                    .build();
        }
        return sqlserverData;
    }
     */

    @DS("db2")
    @Override
    public int matchNum(MatchInfoDTO matchInfoDTO, boolean likeGuiGe, boolean likeDanWei){
        return sqlserverMatchServiceMapper.matchNum(matchInfoDTO,likeGuiGe,likeDanWei);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public String updateMatch(List<SCAccountingDTO> scAccountingDTOS, String total, EmployeeFromSCADTO employee){
        MatchDO matchDO = this.matchServiceMapper.info(CommonUtils.stringNull(scAccountingDTOS.get(0).getMesObjuid()));
        String issueNum = matchDO.getIssueNum();
        log.debug("total:"+ total + "issueNum" + issueNum);
        NumStringUtil numStringUtil = new NumStringUtil();
        if (numStringUtil.numCompareTo(total, issueNum).equals("1")) {
            return "more";
        }
        boolean b = true;
        for (SCAccountingDTO s:scAccountingDTOS) {
            if (b) {
                matchServiceMapper.updateMatch(s,employee);
                b = false;
            } else {
                matchServiceMapper.insertMatch(s,matchDO,employee);
            }
            String stock = numStringUtil.numSub(s.getStock(),s.getBangdingnum());
            s.setStock(stock);
            matchServiceMapper.insertComplete(MesAccountMatchCompleteDTO.builder()
                    .createuid(CommonUtils.stringNull(s.getCreateId()))
                    .factoryId(CommonUtils.stringNull(s.getFactoryId()))
                    .materialfmt(CommonUtils.stringNull(s.getMaterialFmt()))
                    .materialstd(CommonUtils.stringNull(s.getMaterialStd()))
                    .materialmark(CommonUtils.stringNull(s.getMaterialMark()))
                    .registerid(CommonUtils.stringNull(s.getRegisterId()))
                    .unit(CommonUtils.stringNull(s.getUnit()))
                    .stock(stock)
                    .amount(numStringUtil.numDiv(numStringUtil.numSub(s.getJcAmount(),s.getSfAmount()),"1"))
                    .build());
            issueNum = numStringUtil.numSub(issueNum, s.getBangdingnum());
            log.debug("实发数量剩余：" + issueNum);
        }
        System.out.println("numStringUtil.numCompareTo(issueNum, \"0\") = " + numStringUtil.numCompareTo(issueNum, "0"));
        if (numStringUtil.numCompareTo(issueNum, "0").equals("1")) {

            matchDO.setIssueNum(issueNum);
            matchServiceMapper.weiwanquanMatch(matchDO);
        }
        return "ok";
    }

    @Override
    public int countExport(MatchConditionDTO matchConditionDTO) {
        return matchServiceMapper.countExport(matchConditionDTO);
    }

    @DS("db2")
    @Override
    public List<SCAccountingDTO> match(MatchInfoDTO matchInfoDTO, boolean likeGuiGe) {
        return this.sqlserverMatchServiceMapper.matchSCA(matchInfoDTO, likeGuiGe);
    }

    //@DS("db2")
    //@Override
    //public List<SCAccountingDTO> match(MatchInfoDTO matchInfoDTO, int num, boolean likeGuiGe, boolean likeDanWei) {
    //    return this.sqlserverMatchServiceMapper.matchSCA(matchInfoDTO,num,likeGuiGe,likeDanWei);
    //}

    @Override
    public List<MesAccountMatchPrintDTO> queryPrint(String objuidList) {
        List<MesAccountMatchPrintDTO> list = this.matchServiceMapper.queryPrint(objuidList);
        List<MesAccountMatchPrintDTO> result = new ArrayList<>();
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
        DateTimeFormatter df2 = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        LocalDate formatDate = LocalDate.now();
        String date = formatDate.format(df);
        System.out.println("LocalDate => String: " + date);
        int count = this.matchServiceMapper.queryPrintCount();
        StringBuffer barcodePrint = new StringBuffer();
        for (int i = 0; i < list.size(); i++) {
            MesAccountMatchPrintDTO matchPrintDTO = list.get(i);
            String dateString = matchPrintDTO.getCreateTime().format(df2);
            matchPrintDTO.setDateString(dateString);
            if (CommonUtils.stringNull(matchPrintDTO.getBarcodePrint()) == null) {
                barcodePrint.append("C11");
                barcodePrint.append(date);
                String countString = count + "";
                barcodePrint.append(countString);
                int countSize = countString.length();
                if (countSize < 6) {
                    for (int j = 0; j < 6 - countSize; j++) {
                        barcodePrint.append("0");
                    }
                }
                barcodePrint.append(i);
                String code = barcodePrint.toString();
                this.matchServiceMapper.updatebarcodePrint(matchPrintDTO.getObjuid(), code);
                matchPrintDTO.setBarcodePrint(code);
                barcodePrint.setLength(0);
            }
            result.add(matchPrintDTO);
            count++;
        }
        log.debug("result:{}",result);
        return result;
    }

    private List<MesAccountMatchCompleteDTO> complete(List<SCAccountingDTO> match, String factoryId) {
        StringBuffer s = new StringBuffer();
        List<MesAccountMatchCompleteDTO> complete = new ArrayList<>();
        for (SCAccountingDTO scAccountingDTO: match) {
            s.append("'");
            s.append(scAccountingDTO.getRegisterId());
            s.append("',");
        }
        if (s.length() > 1) {
            s.setLength(s.length()-1);
            log.debug("到货登记号拼串：" + s.toString());
            complete = this.matchServiceMapper.complete(MatchInfoDTO.builder()
                    .registerId(s.toString())
                    .factoryId(factoryId)
                    .build());
        }
        return complete;
    }

    /**
     * 根据两边数据库查询结果做数据处理
     * @param complete  匹配过的二级成本核算数据
     * @param match     二级成本核算原始数据
     * @param objuid    匹配条件的主键
     * @param issueNum  实发数量（用于判断实际剩余数量是否大于实发数量）
     * @param count     判断是否为最后一次查询（最后一次查询仅判断数量是否大于0）目前都走最后一次查询
     * @return
     */
    private List<SCAccountingDTO> check(List<MesAccountMatchCompleteDTO> complete, List<SCAccountingDTO> match, String objuid, String issueNum, int count) {
        List<SCAccountingDTO> matchSCA = new ArrayList<>();
        log.debug("二级成本核算匹配数据：{}",match);
        log.debug("匹配过的数据：{}",complete);
        log.debug("实发数量：" + issueNum);
        NumStringUtil numStringUtil = new NumStringUtil();
        if (complete != null && complete.size() > 0 && match != null && match.size() > 0) {
            System.out.println(">>>>>>>>>>>>>>1");
            for (SCAccountingDTO s : match) {
                boolean add = true;
                s.setObjuid(UUID.randomUUID().toString().replace("-", ""));
                s.setMesObjuid(objuid);
                for (MesAccountMatchCompleteDTO m : complete) {
                    String stock = m.getStock();
                    if (s.getRegisterId().equals(m.getRegisterid())) {
                        s.setStock(String.valueOf(stock));
                        s.setJcAmount(m.getAmount());
                        if (count != 3 && numStringUtil.numCompareTo(stock,issueNum).equals("-1")) {
                            add = false;
                            break;
                        }
                        if (count == 3 && numStringUtil.numCompareTo(stock,"0").equals("0")) {
                            add = false;
                            break;
                        }
                    }
                }
                if (add) {
                    matchSCA.add(s);
                }
            }
        }
        if (match != null && match.size() > 0 && (complete == null || complete.size() <= 0)) {
            System.out.println(">>>>>>>>>>>>>>2");
            for (SCAccountingDTO s : match) {
                //boolean add = true;
                s.setObjuid(UUID.randomUUID().toString().replace("-", ""));
                s.setMesObjuid(objuid);
                matchSCA.add(s);
            }
            //matchSCA = match;
        }
        log.debug("数据处理结果：{}", matchSCA);
        return matchSCA;
    }

    @DS("db2")
    @Override
    public EmployeeFromSCADTO employee(String eid){
        return this.sqlserverMatchServiceMapper.selectGdBz(eid);
    }

    /**
     * 已弃用
     * @param matchInfoDTO
     * @return
     */
    //@Override
    //public List<SCAccountingDTO> matchSCA(MatchInfoDTO matchInfoDTO) {
    //    //matchInfoDTO.setLupihao(CommonUtils.stringNull(matchInfoDTO.getLupihao()));
    //    //List<SCAccountingDTO> matchSCA = new ArrayList<>();
    //    //boolean check = true;
    //
    //
    //    //List<SCAccountingDTO> matchSCA1 = sqlserverMatchServiceMapper.matchSCA1(matchInfoDTO);
    //    //List<SCAccountingDTO> matchSCA2 = sqlserverMatchServiceMapper.matchSCA2(matchInfoDTO);
    //    //List<SCAccountingDTO> matchSCA3 = sqlserverMatchServiceMapper.matchSCA3(matchInfoDTO);
    //    //List<SCAccountingDTO> matchSCA4 = sqlserverMatchServiceMapper.matchSCA4(matchInfoDTO);
    //    //List<MesAccountMatchCompleteDTO> complete = matchServiceMapper.complete(matchInfoDTO);
    //    List<SCAccountingDTO> matchSCA = new ArrayList<>();
    //    List<MesAccountMatchCompleteDTO> complete;
    //    //log.debug("已匹配数据：{}", complete);
    //    MatchInfoDTO condition = splitPHGuige(matchInfoDTO);
    //    String objuid = condition.getObjuid();
    //    if (objuid.equals("no")) {
    //        return matchSCA;
    //    }
    //    String issueNum = matchInfoDTO.getIssueNum();
    //    log.debug("匹配情况：",condition);
    //    List<SCAccountingDTO> matchs;
    //    for (int i = 1; i < 5; i++) {
    //        if (matchSCA == null || matchSCA.size() <= 0) {
    //            matchs = this.matchService.match(matchInfoDTO, i);
    //        } else {
    //            matchSCA.get(0).setObjuid("1");
    //            break;
    //        }
    //        if (matchs != null && matchs.size() > 0) {
    //            StringBuffer matchString = new StringBuffer();
    //            int length = matchs.size();
    //            for (int j = 0; j < length; j++) {
    //                SCAccountingDTO scAccountingDTO = matchs.get(j);
    //                if (j < length - 1) {
    //                    matchString.append("'" + scAccountingDTO.getRegisterId() + "',");
    //                } else {
    //                    matchString.append("'" + scAccountingDTO.getRegisterId() + "'");
    //                }
    //            }
    //            complete = this.matchServiceMapper.complete(MatchInfoDTO.builder()
    //                    .registerId(CommonUtils.stringNull(matchString.toString()))
    //                    .factoryId(CommonUtils.stringNull(matchInfoDTO.getFactoryId()))
    //                    .build());
    //            log.debug("已匹配数据"+ i + "：{}", complete);
    //            matchSCA = this.check(complete, matchs, objuid, issueNum, i);
    //            complete.clear();
    //            matchString.setLength(0);
    //        }
    //    }
    //    return matchSCA;
    //}
    //@DS("db2")
    //@Override
    //public int matchNum(MatchInfoDTO matchInfoDTO){
    //    //matchInfoDTO.setLupihao(CommonUtils.stringNull(matchInfoDTO.getLupihao()));
    //    int count = sqlserverMatchServiceMapper.matchNum(matchInfoDTO);
    //    return count;
    //}
    //@DS("db2")
    //public List<SCAccountingDTO> match(MatchInfoDTO matchInfoDTO, int flag) {
    //    List<SCAccountingDTO> matchSCA = new ArrayList<>();
    //    switch (flag) {
    //        case 1:
    //            matchSCA = sqlserverMatchServiceMapper.matchSCA1(matchInfoDTO);
    //            break;
    //        case 2:
    //            matchSCA = sqlserverMatchServiceMapper.matchSCA2(matchInfoDTO);
    //            break;
    //        case 3:
    //            matchSCA = sqlserverMatchServiceMapper.matchSCA3(matchInfoDTO);
    //            break;
    //        case 4:
    //            matchSCA = sqlserverMatchServiceMapper.matchSCA4(matchInfoDTO);
    //            break;
    //    }
    //    log.debug("查询"+ flag + ":{}", matchSCA);
    //    return matchSCA;
    //}

    /**
     * 拆分并返回有结果的数据，已弃用
     * @param matchInfoDTO
     * @return
     */
    //private MatchInfoDTO splitPHGuige(MatchInfoDTO matchInfoDTO){
    //    if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //        return matchInfoDTO;
    //    }
    //    String biaozhun = matchInfoDTO.getMaterialStd();
    //    String paihao = matchInfoDTO.getMaterialMark();
    //
    //    String[] paihaoList = paihao.split("\\/");
    //    if (paihaoList.length > 1) {
    //        for (String s:paihaoList) {
    //            matchInfoDTO.setMaterialMark(s);
    //            if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                return matchInfoDTO;
    //            }
    //        }
    //        matchInfoDTO.setMaterialMark(paihao);
    //    }
    //    if (biaozhun.indexOf("及") != -1) {
    //      String[] list = biaozhun.split("及");
    //        for (String s: list) {
    //            matchInfoDTO.setMaterialStd(s);
    //            if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                return matchInfoDTO;
    //            }
    //        }
    //        matchInfoDTO.setObjuid("no");
    //        return matchInfoDTO;
    //    }
    //    String[] biaozhunList = biaozhun.split("\\)");
    //    if (biaozhunList.length > 1) {
    //        for (String s:biaozhunList) {
    //            matchInfoDTO.setMaterialStd(s);
    //            if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                return matchInfoDTO;
    //            }
    //        }
    //        if (paihaoList.length > 1) {
    //            for (String s:paihaoList) {
    //                matchInfoDTO.setMaterialMark(s);
    //                for (String s2:biaozhunList) {
    //                    matchInfoDTO.setMaterialStd(s2);
    //                    if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                        return matchInfoDTO;
    //                    }
    //                }
    //
    //            }
    //        }
    //    }
    //    String[] biaozhunList2 = new String[5];
    //    int temp0 = 0;
    //    for (String s: biaozhunList) {
    //        String[] temp = s.split("\\(");
    //        for (String s2:temp) {
    //            matchInfoDTO.setMaterialStd(s2);
    //            if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                return matchInfoDTO;
    //            }
    //        }
    //        if (paihaoList.length > 1) {
    //            for (String s3:paihaoList) {
    //                matchInfoDTO.setMaterialMark(s3);
    //                for (String s2:temp) {
    //                    matchInfoDTO.setMaterialStd(s2);
    //                    if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                        return matchInfoDTO;
    //                    }
    //                }
    //            }
    //        }
    //        //for (String s4: temp) {
    //        //    biaozhunList2[biaozhunList2.length] = s4;
    //        //}
    //        for (int i = 0; i < temp.length; i++) {
    //            biaozhunList2[temp0] = temp[i];
    //            temp0++;
    //        }
    //    }
    //    for (int i = 0; i < temp0; i++)  {
    //        String s = biaozhunList2[i];
    //        String[] temp = s.split("\\/");
    //        for (String s2:temp) {
    //            matchInfoDTO.setMaterialStd(s2);
    //            if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                return matchInfoDTO;
    //            }
    //        }
    //        if (paihaoList.length > 1) {
    //            for (String s3:paihaoList) {
    //                matchInfoDTO.setMaterialMark(s3);
    //                for (String s2:temp) {
    //                    matchInfoDTO.setMaterialStd(s2);
    //                    if (this.matchService.matchNum(matchInfoDTO) != 0) {
    //                        return matchInfoDTO;
    //                    }
    //                }
    //            }
    //        }
    //    }
    //    matchInfoDTO.setObjuid("no");
    //    return matchInfoDTO;
    //}

    //private MatchInfoDTO getData(MatchInfoDTO matchInfoDTO) {
    //    List<MatchInfoDTO> condition = new ArrayList<>();
    //    //List<MatchInfoDTO> result = new ArrayList<>();
    //    //String biaozhun = matchInfoDTO.getMaterialStd();
    //    String paihao = matchInfoDTO.getMaterialMark();
    //    String unit = matchInfoDTO.getUnit();
    //    String guige = matchInfoDTO.getMaterialFmt();
    //    //List<String> biaozhunList = splitData(biaozhun);
    //    List<String> paihaoList = new ArrayList<>();
    //    List<String> unitList = new ArrayList<>();
    //    List<String> guigeList = new ArrayList<>();
    //    String[] paihaos = paihao.split("\\/");
    //    paihaoList.add(paihao);
    //    for (String s: paihaos) {
    //        if (s.length() > 0) {
    //            paihaoList.add(s);
    //        }
    //    }
    //    if (unit.toLowerCase().indexOf("kg") != -1 || unit.indexOf("千克") != -1) {
    //        unitList.add("kg");
    //        unitList.add("千克");
    //    } else if (unit.toLowerCase().indexOf("m") != -1 || unit.indexOf("米") != -1) {
    //        unitList.add("m");
    //        unitList.add("米");
    //    } else {
    //        unitList.add(unit);
    //    }
    //    guigeList.add(guige);
    //    if (guige.indexOf("δ") != -1) {
    //        if (guige.indexOf("X") != -1) {
    //            guigeList.add(guige.split("X")[0]);
    //        }
    //        if (guige.indexOf("X") != -1) {
    //            guigeList.add(guige.split("×")[0]);
    //        }
    //    }
    //
    //}

    //private List<String> splitData(String s) {
    //    List<String> stringList = new ArrayList<>();
    //    stringList.add(s);
    //    if (s.indexOf("及") != -1) {
    //        String[] strings = s.split("及");
    //        for (String s1: strings) {
    //            stringList.add(s1);
    //        }
    //        return stringList;
    //    }
    //    List<String> temp = new ArrayList<>();
    //    if (s.indexOf("\\(") != -1 && s.indexOf("\\)") != -1) {
    //        String[] strings = s.split("\\)");
    //        for (String s1: strings) {
    //            String[] strings1 = s1.split("\\(");
    //            for (String s2: strings1) {
    //                if (s2.length() > 1) {
    //                    temp.add(s2);
    //                    stringList.add(s2);
    //                }
    //            }
    //        }
    //    } else {
    //        temp.add(s);
    //    }
    //    for (String s1: temp) {
    //        if (s1.indexOf("\\/") != -1) {
    //            String[] strings = s1.split("\\/");
    //            for (String s2: strings) {
    //                stringList.add(s2);
    //            }
    //        }
    //    }
    //    return stringList;
    //}
}
